#include<bits/stdc++.h>
using namespace std;
long long n,L,R;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld%lld%lld",&n,&L,&R);
	printf("%lld",max(R%n,max(R/n*n-1,L)%n));
	
	return 0;
}
